package com.tea.funct.service.impl;

import com.tea.common.utils.DateUtils;
import com.tea.funct.domain.TeaSubclass;
import com.tea.funct.mapper.TeaSubclassMapper;
import com.tea.funct.service.ITeaSubclassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 产品小类Service业务层处理
 *
 * @author Sophia
 * @date 2024-05-25
 */
@Service
public class TeaSubclassServiceImpl implements ITeaSubclassService {
    @Autowired
    private TeaSubclassMapper teaSubclassMapper;

    /**
     * 查询产品小类
     *
     * @param id 产品小类主键
     * @return 产品小类
     */
    @Override
    public TeaSubclass selectTeaSubclassById(Long id) {
        return teaSubclassMapper.selectTeaSubclassById(id);
    }

    /**
     * 查询产品小类列表
     *
     * @param teaSubclass 产品小类
     * @return 产品小类
     */
    @Override
    public List<TeaSubclass> selectTeaSubclassList(TeaSubclass teaSubclass) {
        return teaSubclassMapper.selectTeaSubclassList(teaSubclass);
    }

    /**
     * 新增产品小类
     *
     * @param teaSubclass 产品小类
     * @return 结果
     */
    @Override
    public int insertTeaSubclass(TeaSubclass teaSubclass) {
        teaSubclass.setCreateTime(DateUtils.getNowDate());
        return teaSubclassMapper.insertTeaSubclass(teaSubclass);
    }

    @Override
    public int insertTeaSubclassAll(List<TeaSubclass> list) {
        return teaSubclassMapper.insertTeaSubclassAll(list);
    }

    /**
     * 修改产品小类
     *
     * @param teaSubclass 产品小类
     * @return 结果
     */
    @Override
    public int updateTeaSubclass(TeaSubclass teaSubclass) {
        teaSubclass.setUpdateTime(DateUtils.getNowDate());
        return teaSubclassMapper.updateTeaSubclass(teaSubclass);
    }

    /**
     * 批量删除产品小类
     *
     * @param ids 需要删除的产品小类主键
     * @return 结果
     */
    @Override
    public int deleteTeaSubclassByIds(Long[] ids) {
        return teaSubclassMapper.deleteTeaSubclassByIds(ids);
    }

    /**
     * 删除产品小类信息
     *
     * @param id 产品小类主键
     * @return 结果
     */
    @Override
    public int deleteTeaSubclassById(Long id) {
        return teaSubclassMapper.deleteTeaSubclassById(id);
    }

    @Override
    public TeaSubclass selectTeaSubclassByName(String subclassName) {
        return teaSubclassMapper.selectTeaSubclassByName(subclassName);
    }

    @Override
    public List<TeaSubclass> selectTeaSubclassListAll(Long categoryId) {
        return teaSubclassMapper.selectTeaSubclassListAll(categoryId);
    }
}
